import React, { Component } from 'react'
import axios from 'axios';
import '../mock/mock'
import {withRouter} from 'react-router-dom'
class item extends Component {
    state={
        data:[]
    }
    componentDidMount(){
        axios.get('/api/data').then((res)=>{
            
          this.setState({
              data:res.data
          })
        })
    }
    render() {
        let {data}=this.state
        return (
            <div>
                {
                 data&&data.map((item,index)=>{
                     return( <div key={index}>
                          <img  src={item.img}  onClick={this.tu.bind(this,item)} />
                     </div>

                     )
                 })   
                }
            </div>
        )
    }
    tu(item){
        let {history}=this.props
          history.push({
              pathname:"/xq",
              query:item
          })
    }
}
export default (withRouter) (item)